<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        html,
        body {
            height: 800px;
        }

        body {
            /* background: rgb(184, 229, 248) url("./img/zhihu.png") 0px 0px/cover no-repeat fixed; */
            background: rgb(184, 229, 248) url("https://files.codelife.cc/wallpaper/wallspic/2023061248k48l.jpeg?x-oss-process=image/resize,limit_0,m_fill,w_2560,h_1440/quality,Q_95/format,webp") 0px 0px/cover no-repeat fixed;
        }

        h3 {
            display: block;
            margin: 0 auto;
        }

        #big_biv {
            height: 450px;
            width: 100%;
            margin: 0 auto;
            margin-top: 20px;
        }

        h3 {
            font-size: 50px;
            line-height: 90px;
            text-align: center;
        }

        p {
            text-align: center;
            font-size: 12px;
        }

        #p1 {
            margin-bottom: 40px;
        }

        .wenbeng {
            color: #fff;
            margin-top: 30px;
        }

        .cent_div {
            margin: 0 auto;
            height: 500px;
            width: 700px;
            background-color: rgba(255, 255, 255, 0.5);
            display: flex;
            justify-content: center;
            align-items: center;
            box-shadow: 15px 10px 10px 17px rgba(0, 0, 0, 0.2);
        }

        .form {
            width: 60%;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .form div {
            display: flex;
            justify-content: flex-start;
            align-items: center;
            margin-bottom: 20px;
            width: 100%;
        }

        .form label {
            font-size: 18px;
            margin-right: 10px;
            white-space: nowrap;
        }

        .form input {
            width: 250px;
            height: 30px;
            padding: 5px;
            border: none;
            border-bottom: 2px solid #000;
            outline: none;
            font-size: 16px;
        }

        .form div:last-child {
            display: flex;
            justify-content: center;
            margin-top: 10px;
        }

        .form button {
            padding: 10px 20px;
            font-size: 16px;
            border: none;
            background-color: #007BFF;
            color: white;
            cursor: pointer;
            border-radius: 5px;
            margin-right: 10px;
        }

        .form button:last-child {
            margin-right: 0;
        }
    </style>
</head>

<body>
    <div id="big_biv">
        <h3>智能温室管理</h3>
        <p id="p1">让养花&nbsp;&nbsp;&nbsp;变得容易</p>

        <div class="cent_div">
            <form class="form" action="">
                <div>
                    <label for="uname">账号：</label>
                    <input id="uname" name="uname" type="text" placeholder="请输入账号">
                </div>
                <div>
                    <label for="upwd">密码：</label>
                    <input id="upwd" name="upwd" type="password" placeholder="请输入8位密码">
                </div>
                <div>
                    <button type="button" onclick="login()">登陆</button>
                    <button type="button" onclick="register()">注册</button>
                </div>
            </form>
        </div>

        <p class="wenbeng">智能花卉管理系统研发移动应用联系我们来三玖工作注册机构号ZhongYe SanJiu<br> © 2024 三玖京 ICP 证 111111 号京 ICP 备 11111111 号
            - <img src="https://pic3.zhimg.com/80/v2-d0289dc0a46fc5b15b3363ffa78cf6c7.png" alt="">1京公网安备
            1111111111111 号京网文[2022]2674-000 号出版物经营许可证药品医疗器械网络信息服务备案（京）网药械信息备字（0000）第00000号<br>
            广播电视节目制作经营许可证:（京）字第00000号互联网宗教信息服务许可证：京（2022）0000000<br>
            侵权举报网上有害信息举报专区儿童色情信息举报专区互联网算法推荐举报专区违法和不良信息举报：010-82716601举报邮箱：jubao@zhihu.com
        </p>
    </div>
    <script>
        function login() {
            const form = document.querySelector('.form');
            const uname = form.uname.value;
            const upwd = form.upwd.value;
            if (uname == "root" && upwd == "root") {
                window.location.href = "idx.html";
            }else{
                alert("登录失败！");
            }
        }
    </script>


    <!--     <script>
        // 登录逻辑
        function login() {
            const form = document.querySelector('.form');
            const uname = form.uname.value;
            const upwd = form.upwd.value;

            if (!/[\s]+/.test(uname) && /[\D]+/.test(upwd) && /[\d]+/.test(upwd) && /[\w]{6,12}/.test(upwd)) {
                let req_data = { name: uname, pwd: upwd };

                fetch("/cgi-bin/login", {
                    method: "POST",
                    body: JSON.stringify(req_data),
                    headers: {
                        "content-type": "application/json;charset=utf-8"
                    }
                })
                    .then(resp => resp.json())
                    .then(data => {
                        if (data.code == 0) {
                            localStorage.uid = data.user.id;
                            localStorage.nickname = data.user.nickname;
                            localStorage.head = data.user.head;
                            // alert("登录成功，用户：" + data.user.nickname);
                            location.href = "/project/index.html";
                        } else {
                            alert("登录失败：" + data.msg);
                        }
                    })
                    .catch(error => {
                        console.error('Error:', error);
                        alert("请求失败，请稍后再试。");
                    });
            } else {
                alert("账号或密码格式有误");
            }
        }

        // 注册逻辑
        function register() {
            const form = document.querySelector('.form');
            const uname = form.uname.value;
            const upwd = form.upwd.value;

            if (!/[\s]+/.test(uname) && /[\D]+/.test(upwd) && /[\d]+/.test(upwd) && /[\w]{6,12}/.test(upwd)) {
                let temp = Math.floor(Math.random() * 4) + 1;
                let src = "/img/head" + temp + ".png";
                let req_data = { name: uname, pwd: upwd, head: src };

                // 打印发送的 JSON 数据
                console.log("Sending JSON Data: ", JSON.stringify(req_data));

                fetch("/cgi-bin/register", {
                    method: "POST",
                    body: JSON.stringify(req_data),
                    headers: {
                        "content-type": "application/json;charset=utf-8"
                    }
                })
                    .then(resp => resp.json())
                    .then(data => {
                        if (data.code === 0) {
                            alert("注册成功，用户：" + data.user.nickname);
                            // location.href = "/project/idx.html";
                        } else {
                            alert("注册失败：" + data.msg);
                        }
                    })
                    .catch(error => {
                        console.error('Error:', error);
                        alert("请求失败，请稍后再试。");
                    });
            } else {
                alert("账号或密码格式有误注册失败!");
            }
        }


    </script> -->
</body>

</html>